package com.lc.afbx.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONObject;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

/**
 * Created by shenyuxin on 2016/11/1.
 */
@HttpInlet(Conn.APISDK_VEHICLECARD)
public class PostVehicleCard extends BaseAsyPost<PostVehicleCard.VehicleCardEntity> {

    public String userid, time, lock, base;

    public PostVehicleCard(AsyCallBack<VehicleCardEntity> asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected VehicleCardEntity parser(JSONObject object) {


        if (object.optInt("code") == 200) {

            VehicleCardEntity vehicleCardEntity = new VehicleCardEntity();

            JSONObject dataObject = object.optJSONObject("data");

            JSONObject entityObject = dataObject.optJSONObject("vehicleCard");


            vehicleCardEntity.plateno = entityObject.optString("plateno");
            vehicleCardEntity.vehicletype = entityObject.optString("vehicletype");
            vehicleCardEntity.owner = entityObject.optString("owner");
            vehicleCardEntity.veaddress = entityObject.optString("veaddress");
            vehicleCardEntity.usecharacter = entityObject.optString("usecharacter");
            vehicleCardEntity.engineno = entityObject.optString("engineno");
            vehicleCardEntity.model = entityObject.optString("model");

            vehicleCardEntity.vin = entityObject.optString("vin");
            vehicleCardEntity.registerdate = entityObject.optString("registerdate");
            vehicleCardEntity.issuedate = entityObject.optString("issuedate");
            vehicleCardEntity.cropped_image = entityObject.optString("cropped_image");


            return vehicleCardEntity;


        }


        TOAST = object.optString("message");

        return null;
    }

    @Override
    protected boolean skipSecret(String key) {

        return key.equals("base");
    }


    public static class VehicleCardEntity {

//        "data": {
//            "code": "0",
//                    "result": "118.12.0.12",
//                    "vehicleCard": {
//                "plateno": "黑A628UF",
//                        "vehicletype": "小型轿车",
//                        "owner": "邓锐",
//                        "veaddress": "哈尔滨市香坊区轴承三道街号4单元201",
//                        "usecharacter": "非营运",
//                        "engineno": "B65J056875",
//                        "model": "长安牌5盯I06肿B",
//                        "vin": "LS5A3BBD5BA551400",
//                        "registerdate": "2011-09-21",
//                        "issuedate": "2015-05-05",
//                        "cropped_image": null
//            }
//        }

        public String plateno, vehicletype, owner, veaddress, usecharacter, engineno, model, vin, registerdate, issuedate, cropped_image;

    }


}
